package com.gp.adapter;

import java.util.ArrayList;

import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;

  public class NavigationPageAdapter extends PagerAdapter {
   
   
    private ArrayList<View> pageViews;
    
    public NavigationPageAdapter(ArrayList<View> pArrayList) {
        
        this.pageViews = pArrayList;
        
    }
    @Override
    public int getCount() {
        return pageViews.size();
    }

    @Override
    public boolean isViewFromObject(View arg0, Object arg1) {
        return arg0 == arg1;
    }

    // 初始化每个Item
    @Override
    public Object instantiateItem(View container, int position) {
        ((ViewPager) container).addView(pageViews.get(position));
        return pageViews.get(position);
    }

    // 销毁每个Item
    @Override
    public void destroyItem(View container, int position, Object object) {
        ((ViewPager) container).removeView(pageViews.get(position));
    }

}